
@extends('layouts.admin')
@section('contents')
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; 添加产品
</div>
<!--面包屑导航 结束-->
<!--结果页快捷搜索框 开始-->
<div class="search_wrap">
    <form action="" method="post">
        <table class="search_tab">
            <tr>
                <th width="120">选择分类:</th>
                <td>
                    <select onchange="javascript:location.href=this.value;">
                        <option value="">全部</option>
                        <option value="http://www.baidu.com">百度</option>
                        <option value="http://www.sina.com">新浪</option>
                    </select>
                </td>
                <th width="70">关键字:</th>
                <td><input type="text" name="keywords" placeholder="关键字"></td>
                <td><input type="submit" name="sub" value="查询"></td>
            </tr>
        </table>
    </form>
</div>
<!--结果页快捷搜索框 结束-->


<!--结果集标题与导航组件 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>添加产品</h3>
        <!--快捷导航 开始-->
        <div class="result_content">
            <div class="short_wrap">
                <a href="{{url('admin/product/create')}}"><i class="fa fa-plus"></i>新增产品</a>
                <a href="{{url('admin/product')}}"><i class="fa fa-recycle"></i>全部产品</a>
            </div>
        </div>
        <!--快捷导航 结束-->
        @if(count($errors) > 0)
            <div class="mark"> 
            @if(is_object($errors))
                @foreach($errors->all() as $error)
                <p>{{$error}}</p>
                @endforeach
            @else
                <p>{{$errors}}</p>
            @endif
            </div>
        @endif
    </div>
</div>

<div class="result_wrap">
    <form action="{{url('admin/product')}}" method="post" enctype="multipart/form-data">
        {{csrf_field()}}
        <table class="add_tab">
            <tbody>
                <tr>
                    <th><i class="require">*</i>产品名称：</th>
                    <td>
                        <input type="text" class="lg" name="product_name">产品名称必须填写
                    </td>
                </tr>
                <tr>
                    <th><i class="require">*</i>产品分类：</th>
                    <td>
                        <select name="product_cate_id">
                            @foreach($cate as $c)
                            <option value="{{$c->cate_id}}">{{$c->prefix_cate_name}}</option>
                            @endforeach
                        </select>
                    </td>
                </tr>                
                <tr>
                    <th>产品图片：</th>
                    <td>
                        <input name="product_thumb" type="txt" multiple="true">
                        <input id="file_upload" type="file" multiple="true">
                        <img id="preview_thumb" style="max-width:300px;max-height:100px;"/>
                    </td>
                    <script src="{{asset('resources/org/uploadify/jquery.uploadify.min.js')}}" type="text/javascript"></script>
                    <link rel="stylesheet" type="text/css" href="{{asset('resources/org/uploadify/uploadify.css')}}">
                    <script type="text/javascript">
                    <?php $timestamp = time(); ?>
                    $(function() {
                        $('#file_upload').uploadify({
                                'buttonText' : '选择图片',
                                'formData'     : {
                                        'timestamp' : '<?php echo $timestamp; ?>',
                                        '_token'     : '{{csrf_token()}}'
                                },
                                'swf'      : "{{asset('resources/org/uploadify/uploadify.swf')}}",
                                'uploader' : "{{url('admin/upload')}}",
                                'onUploadSuccess' : function(file, data, response) {
                                    $('input[name=product_thumb]').val(data);
                                    $('#preview_thumb').attr('src', data);
                                }
                        });
                    });
                    </script>
                    <style>
                    .uploadify{display:inline-block;}
                    .uploadify-button{border:none; border-radius:5px; margin-top:8px;}
                    table.add_tab tr td span.uploadify-button-text{color: #FFF; margin:0;}
                    </style>
                </tr>
                <tr>
                    <th>产品描述：</th>
                    <td>
                        <textarea name="product_description"></textarea>
                    </td>
                </tr>    
                <tr>
                    <th><i class="require">*</i>产品价格：</th>
                    <td>
                        <input type="text" class="sm" name="product_price">
                    </td>
                </tr>                   
                <tr>
                    <th>产品关键词：</th>
                    <td>
                        <input name="product_keywords" class="lg" type="txt">
                    </td>
                </tr>                 
                <tr>
                    <th></th>
                    <td>
                        <input type="submit" value="提交">
                        <input type="button" class="back" onclick="history.go(-1)" value="返回">
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
@endsection


